package org.graudation.verifyCode.controller;

import org.graduation.model.common.ResponseResult;
import org.graduation.model.common.verifyCode.VerifyCode;
import org.graudation.verifyCode.service.VerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verify-code")
public class VerifyCodeController {
    private VerifyCodeService verifyCodeService;

    @PostMapping("/send")
    public ResponseResult sendVerifyCode(@RequestBody VerifyCode verifyCode) {
        return verifyCodeService.sendCode(verifyCode);
    }

    @PostMapping("/verify")
    public ResponseResult verifyCode(@RequestBody VerifyCode verifyCode) {
        return verifyCodeService.verifyCode(verifyCode);
    }

    @GetMapping("/test/v")
    public ResponseResult sendTest() {
        VerifyCode verifyCode = new VerifyCode();
        verifyCode.setUser("814423026@qq.com");
        verifyCode.setServiceName("user");
        verifyCode.setCode("12345");
        return verifyCodeService.verifyCode(verifyCode);
    }

    @Autowired
    public void setVerifyCodeService(VerifyCodeService verifyCodeService) {
        this.verifyCodeService = verifyCodeService;
    }
}

